<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<?php
    header('Content-Type:text/html;charset=utf-8');
    $ch = curl_init();
    $url = 'http://apis.baidu.com/txapi/naowan/naowan';
    $header = array(
        'apikey: 11f709693806656bfbd9d8508109e9fa',
    );
    // 添加apikey到header
    curl_setopt($ch, CURLOPT_HTTPHEADER  , $header);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    // 执行HTTP请求
    curl_setopt($ch , CURLOPT_URL , $url);
    $res = curl_exec($ch);
    $q=json_decode($res);
    $n=$q->newslist[0]->quest;
    $jg=$q->newslist[0]->result;
    echo "脑筋急转弯的问题是：$n";
    echo "答案是：$jg";
?>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php
        // put your code here
        ?>
    </body>
</html>
